package com.GlobalPaint.app.Adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.GlobalPaint.app.R;
import com.GlobalPaint.app.bean.General;
import com.GlobalPaint.app.ui.App;

import java.util.List;

/**
 * Created by Administrator on 2016/11/21 0021.
 *
 */

public class GridViewAdapter extends BaseAdapter {

    private List<General>mGeneralList;
    public GridViewAdapter(List<General>mGeneralList){
        this.mGeneralList = mGeneralList;
    }
    @Override
    public int getCount() {
        return mGeneralList.size();
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view;
        //如果convertView为空,则创建
        if (convertView == null){
            view = View.inflate(App.context, R.layout.home_gridview,null);
        }else{
            view = convertView;
        }

        ImageView iv_icon = (ImageView) view.findViewById(R.id.iv_icon);
        TextView tv_text = (TextView) view.findViewById(R.id.tv_text);
        tv_text.setText(mGeneralList.get(position).getText());
        iv_icon.setImageResource(mGeneralList.get(position).getIcon());
        return view;
    }



    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }
}
